package indus.icalendarFileGenerator;

import static org.junit.Assert.*;
import org.junit.Test;

/**
 *  The Junit tests for the IcsFileGeneratorDriver and Event classes
 *
 *  @author Team Indus
 *  @date August 13th 2014
 *  @bugs None
 */
public class CalendarTest {

	@Test
	public void eventFile() {
		//Calls all the Event methods in the order as it would in the main method
    System.out.println("Calling eventFile test case");
		Event event = new Event();
		String icsFileText;
    
    icsFileText = "BEGIN:VCALENDAR\n" +
     "VERSION:" + event.getVersion() + "\n" +
    "STATUS:" + event.getStatus() + "\n" +
    "X-WR-TIMEZONE:" + event.getTimeZoneIdentifier() + "\n" +
    "BEGIN:VEVENT\n" +
    "DTSTART;TZID="+event.getTimeZoneIdentifier()+":"+event.getStartDate()+ "T" + event.getStartTime() +"00\n"+
    "DTEND;TZID="+event.getTimeZoneIdentifier()+":"+event.getEndDate()+ "T" + event.getEndTime() +"00\n"+
    "SUMMARY:" + event.getSummary() + "\n" +
    "LOCATION:" + event.getLocation() + "\n" +
    "CLASS:" + event.getClassification() + "\n" +
    "GEO:" + event.getGEO() + "\n" +
    "PRIORITY:" + event.getPriorityValue() + "\n" +
    "END:VEVENT\n" +
    "END:VCALENDAR\n";
    System.out.println("Initial file before contents are set: ");
    System.out.println(icsFileText);
    
      System.out.println("New event object created...\n");
      System.out.println("Calling event.setVersion()...");

    event.setVersion();

    	System.out.println("End of setVersion()...\n");
    	System.out.println("Calling event.setStatus()...");
  
    event.setStatus();

      System.out.println("End of setStatus()...\n");
      System.out.println("Calling event.setSummary()...");
    
    event.setSummary();

      System.out.println("End of setSummary()...\n");
      System.out.println("Calling event.setLocation()...");

    event.setLocation();

      System.out.println("End of setLocation()...\n");
      System.out.println("Calling event.setTimeZoneIdentifier()...");

    event.setTimeZoneIdentifier();

      System.out.println("End of setTimeZoneIdentifier()...\n");
      System.out.println("Calling event.setStartDate()...");

    event.setStartDate();
    
      System.out.println("End of setStartDate()...\n");
      System.out.println("Calling event.setEndDate()...");
      
    event.setEndDate();
      
      System.out.println("End of setEndDate()...\n");
      System.out.println("Calling event.setStartTime()...");
      
    event.setStartTime();
      
      System.out.println("End of setStartTime()...\n");
      System.out.println("Calling event.setEndDate()...");
      
    event.setEndTime();
      
      System.out.println("End of setEndTime...\n");
      System.out.println("Calling event.setReoccurenceText()...");
      
    event.setReoccurrenceText();
      
      System.out.println("End of setReoccurenceText...\n");
      System.out.println("Calling event.setClassification...");
      
    
    event.setClassification();

      System.out.println("End of setClassification()...\n");
      System.out.println("Calling event.setGEO()...");

    event.setGEO();

      System.out.println("End of setGEO()...\n");
      System.out.println("Calling event.setPriorityValue()...");

    event.setPriorityValue();

    	System.out.println("End of setPriorityValue()...\n");
  	  System.out.println("Creating text for ics file...");
  	  
  	  icsFileText = "BEGIN:VCALENDAR\n" +
  	      "VERSION:" + event.getVersion() + "\n" +
  	     "STATUS:" + event.getStatus() + "\n" +
  	     "X-WR-TIMEZONE:" + event.getTimeZoneIdentifier() + "\n" +
  	     "BEGIN:VEVENT\n" +
  	     "DTSTART;TZID="+event.getTimeZoneIdentifier()+":"+event.getStartDate()+ "T" + event.getStartTime() +"00\n"+
  	     "DTEND;TZID="+event.getTimeZoneIdentifier()+":"+event.getEndDate()+ "T" + event.getEndTime() +"00\n"+
  	     "SUMMARY:" + event.getSummary() + "\n" +
  	     "LOCATION:" + event.getLocation() + "\n" +
  	     "CLASS:" + event.getClassification() + "\n" +
  	     "GEO:" + event.getGEO() + "\n" +
  	     "PRIORITY:" + event.getPriorityValue() + "\n" +
  	     "END:VEVENT\n" +
  	     "END:VCALENDAR\n";
  	  System.out.println("Final ics file contents: ");
  	  System.out.println(icsFileText);
  	  System.out.println("End of eventFile test case\n");
	}
	
	
	@Test
	public void timeTest() {
		//Checks start and end times
		System.out.println("Calling timeTest test case");
		Event event = new Event();
		System.out.printf("Initial start time: %s\n", event.getStartTime());
		event.setStartTime();
		assertNotNull(event.getStartTime());
		System.out.printf("Start time after input: %s\n", event.getStartTime());
		System.out.println(event.getStartTime());
		System.out.printf("Initial end time: %s\n", event.getEndTime());
		event.setEndTime();
		assertNotNull(event.getEndTime());
		System.out.printf("Start time after input: %s\n", event.getEndTime());
		System.out.println(event.getEndTime());
		System.out.println("End of timeTest test case\n");
	}

	@Test
	public void GEOTest() {  
	  //Checks GEO value
		System.out.println("Calling GEOTest test case");
		Event event = new Event();
	  event.setGEO();
	  assertNotNull(event.getGEO());
	  System.out.printf("GEO should equal 21.445634;-157.918854; actual: %s\n", event.getGEO());
	  assertTrue(event.getGEO().compareTo("21.445634;-157.918854") == 0);
	  System.out.println("End of GEOTest test case\n");
	}
	  
	@Test
	public void statusTest() {  
	  //Checks status
		System.out.println("Calling statusTest test case");
	  Event event = new Event();
	  event.setStatus();
	  assertNotNull(event.getStatus());
	  System.out.printf("Status should equal 'CONFIRMED'; actual: %s\n", event.getStatus());
	  assertTrue(event.getStatus().compareTo("CONFIRMED") == 0);
	  System.out.println("End of statusTest test case\n");
	}
	  
	@Test
	public void versionTest() {  
	  //Checks version
		System.out.println("Calling versionTest test case");
		Event event = new Event();
		event.setVersion();
		assertNotNull(event.getVersion());
		System.out.printf("Version should equal '2.0'; actual: %s\n", event.getVersion());
		assertTrue(event.getVersion().compareTo("2.0") == 0);
		System.out.println("End of versionTest test case\n");
	}
		
		
	@Test
	public void summaryTest() {
	  //Checks summary
		System.out.println("Calling summaryTest test case");
	  Event event = new Event();
		assertNotNull(event.getSummary());
		System.out.printf("Initial summary: %s\n", event.getSummary());
		event.setSummary();
		assertNotNull(event.getSummary());
		System.out.printf("Summary after input: %s\n", event.getSummary());
		System.out.println("End of summaryTest test case\n");
	}
		
	@Test
	public void locationTest() {
		//Checks location
		System.out.println("Calling locationTest test case");
	  Event event = new Event();
		assertNotNull(event.getLocation());
		System.out.printf("Initial location: %s\n", event.getLocation());
		event.setLocation();
		assertNotNull(event.getLocation());
		System.out.printf("Location after input: %s\n", event.getLocation());
		System.out.println("End of locationTest test case\n");
	}
		
	@Test
	public void timeZoneTest() {
		//Checks time zone
		System.out.println("Calling timeZoneTest test case");
		Event event = new Event();
		event.setTimeZoneIdentifier();
		assertNotNull(event.getTimeZoneIdentifier());
		System.out.printf("Time zone should equal 'Pacific/Honolulu'; actual: %s\n", event.getTimeZoneIdentifier());
		assertTrue(event.getTimeZoneIdentifier().compareTo("Pacific/Honolulu") == 0);
		System.out.println("End of timeZoneTest test case\n");
	}
		
	@Test
	public void classificationTest() {
		//Checks classification
		System.out.println("Calling classificationTest test case");
		Event event = new Event();
		assertNotNull(event.getClassification());
		System.out.printf("Initial classification: %s\n", event.getClassification());
		event.setClassification();
		assertNotNull(event.getClassification());
		System.out.printf("Classification after input: %s\n", event.getClassification());
		System.out.println("End of classificationTest test case\n");
	}
	
	@Test
	public void priorityTest() {
		//Checks priority
		System.out.println("Calling priorityTest test case");
		Event event = new Event();
		assertNotNull(event.getPriorityValue());
		System.out.printf("Initial priority: %s\n", event.getPriorityValue());
		event.setPriorityValue();
		assertNotNull(event.getPriorityValue());
		System.out.printf("Priority after input: %s\n", event.getPriorityValue());
		System.out.println("End of priorityTest test case\n");
	}
	
	@Test
	public void dateTest() {
		//Checks start date
		System.out.println("Calling dateTest test case");
		Event event = new Event();
		assertNotNull(event.getStartDate());
		System.out.printf("Initial start date: %s\n", event.getStartDate());
		event.setStartDate();
		assertNotNull(event.getStartDate());
		System.out.printf("Start date after input: %s\n", event.getStartDate());
		//Checks end date
		assertNotNull(event.getEndDate());
		System.out.printf("Initial end date: %s\n", event.getEndDate());
		event.setEndDate();
		assertNotNull(event.getEndDate());
		System.out.printf("End date after input: %s\n", event.getEndDate());
		//Checks start time
		System.out.println(event.getStartTime());
		//Checks end time
		System.out.println(event.getEndTime());
		//Checks reoccurence methods
		System.out.printf("Initial recurrence variable: %s\n", event.getReoccurrenceText());
		event.setReoccurrenceText();
		assertNotNull(event.getReoccurrenceText());
		System.out.printf("Recurrence value after input: %s\n", event.getReoccurrenceText());
		System.out.println("End of reoccurrenceTest test case\n");
		System.out.println("End of dateTest test case\n");
	}
	
	
	

}